package com.me.test.config;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.annotation.Order;

/**
 * AOP学习: AspectJ 配置
 *      https://docs.spring.io/spring-framework/docs/4.3.12.RELEASE/spring-framework-reference/html/aop.html#aop-ataspectj
 *
 * @author ME
 * @date   2019/11/13
 */
@Aspect
public class AspectJConfig implements PriorityOrdered {

    @Override
    public int getOrder() {
        // 保证事务等切面先执行
        return Integer.MAX_VALUE;
    }

    /**
     * 方法的一切定义都可以描述: 修饰符、返回类型、包名、方法名、方法参数
      */
    @Pointcut("execution(public * com.me.test.service.*.*(..))")
    public void pointCutExecution() {
    }

    @Before("pointCutExecution()")
    @Order(1)
    public void before111(JoinPoint joinPoint) {
        System.out.println("[Before advice111] getThis(): " + joinPoint.getThis());
    }

}
